// 医护管理-用药登记

import r from '@/utils/request';
import type { ResponseType, ListParams, ListResponseType } from '../types';

enum API {
    drugsList = '/drugs/list', // 存药登记列表
    drugsListForElderly = '/drugs/listForElderly', // 获取老人存药记录
    drugsGet = '/drugs/get', // 获取单条存药登记信息
    drugsDelete = '/drugs/delete', // 删除存药登记信息
    drugsAdd = '/drugs/add', // 存药登记添加
    drugsUpdate = '/drugs/update', // 存药登记信息修改
    drugsDelAll = '/drugs/deleteAll',
}

//批量删除
export function drugsDelAllAPI(ids: number[]): Promise<ResponseType> {
  return r.post(API.drugsDelAll, ids);
}

export interface DrugsItem {
    id: number;
    elderlyId: number;
    elderlyName: string;
    counts: number;
    addAccountName: string;
    addTime: string;
  }

// 存药登记列表参数
interface drugsListParams extends ListParams {
    name: string;
    beginDate: string;
    endDate: number;
    begId: string;
}

// 存药登记列表返回值
type drugsListRes = ListResponseType<{
    id: number;
    companyId: number;
    elderlyId: number;
    addTime: string;
    familyName: string;
    name: string;
    counts: number;
    unit: string;
    expTime: string;
    sum: number;
    norms: string;
    remarks: string;
    addAccountId: number;
    begId: number;
    begName: string;
    idCard: string;
    addAccountName: string;
    elderlyName: string;
    elderlyPhoto: string;
    elderlyGender: string;
    elderlyIdCard: string;
    houseName: string;
    buildingName: string;
    startDate: string;
    endDate: string;
    plans: string;
}>

// 存药登记列表接口
export function drugsListAPI(params: drugsListParams): Promise<drugsListRes> {
    return r.get(API.drugsList, params)
}

// 获取老人存药记录返回值
type drugsListForElderlyRes = ListResponseType<{
    id: number;
    companyId: number;
    elderlyId: number;
    addTime: string;
    familyName: string;
    name: string;
    counts: number;
    unit: string;
    expTime: string;
    sum: number;
    norms: string;
    remarks: string;
    addAccountId: number;
    begId: number;
    begName: string;
    idCard: string;
    addAccountName: string;
    elderlyName: string;
    elderlyPhoto: string;
    elderlyGender: string;
    elderlyIdCard: string;
    houseName: string;
    buildingName: string;
    startDate: string;
    endDate: string;
    plans: string;
}>

// 获取老人存药记录接口
export function drugsListForElderlyAPI(id: number): Promise<drugsListForElderlyRes> {
    return r.get(API.drugsListForElderly + '/' + id)
}

// 获取单条存药登记信息返回值
type drugsGetRes = ResponseType<{
    id: number;
    companyId: number;
    elderlyId: number;
    addTime: string;
    familyName: string;
    name: string;
    counts: number;
    unit: string;
    expTime: string;
    sum: number;
    norms: string;
    remarks: string;
    addAccountId: number;
    begId: number;
    begName: string;
    idCard: string;
    addAccountName: string;
    elderlyName: string;
    elderlyPhoto: string;
    elderlyGender: string;
    elderlyIdCard: string;
    houseName: string;
    buildingName: string;
    startDate: string;
    endDate: string;
    plans: string;
}>

// 获取单条存药登记信息接口
export function drugsGetAPI(id: number): Promise<drugsGetRes> {
    return r.get(API.drugsGet + '/' + id)
}

// 删除存药登记信息接口
export function drugsDeleteAPI(id: number): Promise<ResponseType<string>> {
    return r.delete(API.drugsDelete + '/' + id)
}


// 查房记录信息添加参数
export interface drugsAddParams {
    elderlyId: number;
    addTime: string;
    familyName: string;
    name: string;
    counts: number | undefined;
    unit: string;
    expTime: string;
    sum: number | undefined;
    norms: string;
    remarks: string;
}

// 查房记录信息添加返回值
type drugsAddRes = ResponseType<{
    id: number;
    companyId: number;
    elderlyId: number;
    addTime: string;
    familyName: string;
    name: string;
    counts: number;
    unit: string;
    expTime: string;
    sum: number;
    norms: string;
    remarks: string;
    addAccountId: number;
    begId: number;
    begName: string;
    idCard: string;
    addAccountName: string;
    elderlyName: string;
    elderlyPhoto: string;
    elderlyGender: string;
    elderlyIdCard: string;
    houseName: string;
    buildingName: string;
    startDate: string;
    endDate: string;
    plans: string;
}>

// 查房记录信息添加接口
export function drugsAddAPI(params: drugsAddParams): Promise<drugsAddRes> {
    return r.post(API.drugsAdd, params)
}


// 查房记录信息添加参数
export interface drugsUpdateParams {
    id: number;
    elderlyId: number;
    addTime: string;
    familyName: string;
    name: string;
    counts: number | undefined;
    unit: string;
    expTime: string;
    sum: number | undefined;
    norms: string;
    remarks: string;
}

// 查房记录信息添加返回值
type drugsUpdateRes = ResponseType<{
    id: number;
    companyId: number;
    elderlyId: number;
    addTime: string;
    familyName: string;
    name: string;
    counts: number;
    unit: string;
    expTime: string;
    sum: number;
    norms: string;
    remarks: string;
    addAccountId: number;
    begId: number;
    begName: string;
    idCard: string;
    addAccountName: string;
    elderlyName: string;
    elderlyPhoto: string;
    elderlyGender: string;
    elderlyIdCard: string;
    houseName: string;
    buildingName: string;
    startDate: string;
    endDate: string;
    plans: string;
}>

// 查房记录信息添加接口
export function drugsUpdateAPI(params: drugsUpdateParams): Promise<drugsUpdateRes> {
    return r.put(API.drugsUpdate, params)
}